/***
 * 此文件创建home组件的小仓库
 */

import {reqCategoryList,reqBannerList,reqFloorList} from '@/api'

const actions = {
    async getCategoryList(miniStore){
        let value = await reqCategoryList()
        if(value.code >= 200 && value.code < 300){
            miniStore.commit('GETCATEGORYLIST',value.data)
        } 
    },
    //获取轮播图虚拟数据
    async getBannerList(miniStore){
        let result = await reqBannerList()
        if(result.code === 200){
            miniStore.commit('GETBANNERLIST',result.data)
        }
    },
    async getFloorInfo(miniStore){
        let result = await reqFloorList()
        if(result.code === 200){
            miniStore.commit('GETFLOORINFO',result.data)
        }
    }
};

const mutations = {
    GETCATEGORYLIST(state,value){
        state.categoryList = value
    },
    GETBANNERLIST(state,banner){
        state.bannerList = banner
    },
    GETFLOORINFO(state,floorInfoList){
        state.floorInfoList = floorInfoList
    }
};

const state = {
    categoryList:[],
    bannerList:[],
    floorInfoList:[]
};

const getters = {};

export default {
    actions,
    mutations,
    state,
    getters
}
